<template>
  <div style="min-width:1366px;">
    <!-- 搜索栏区域 -->
    <el-card class="SearchCard" body-style="padding:0px">
      <el-row>
        <el-col :span="2">
          <div class="SearchTitle">条件搜索栏</div>
        </el-col>
        <el-col :span="4">
          <el-row>
            <el-col :span="10">
              <div class="SearchLable">搜索关键字</div>
            </el-col>

            <el-col :span="14">
              <div class="SearchLable">
                <el-input placeholder="请输入内容" v-model="queryInfo.srm" clearable @clear="clearEvent"></el-input>
              </div>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="2">
          <div class="SearchLable">
            <el-button size="medium" type="primary" @click="getSearchList()">搜索</el-button>
          </div>
        </el-col>
      </el-row>
    </el-card>
    <el-card class="TableCard" :body-style="{ padding: '0px' }">
      <div>
        <el-table
          :data="tableData"
          border
          :header-cell-style="{ 'text-align':'center',background: '#3F9DFD', color: '#FFF' }"
          :cell-style="{'text-align':'center'}"
          size="medium"
          stripe
          ref="table"
          :height="tableHeight"
          style="width: 100%;font-size:12px"
        >
          <el-table-column type="index" label="序列号" width="60"></el-table-column>
          <el-table-column prop="drugCode" label="药品编码" width="80"></el-table-column>
          <el-table-column label="操作" width="120">
            <template slot-scope="scope">
              <el-button
                v-if="scope.row.adverseDrugId>0"
                type="text"
                @click="showRuleAdverse(scope.row.adverseDrugId,scope.row.drugName)"
              >查看</el-button>
              <el-button type="text" @click="addReactRule(scope.row.drugCode,scope.row.drugName)">新增</el-button>
            </template>
          </el-table-column>

          <el-table-column prop="drugName" label="药品名称"></el-table-column>
          <el-table-column prop="nameType" label="药品类型">
            <template
              slot-scope="scope"
            >{{(scope.row.nameType==8)?"西药":(scope.row.nameType==2)?"草药":"中成药"}}</template>
          </el-table-column>
          <el-table-column prop="formName" label="剂型名称"></el-table-column>
          <el-table-column prop="drugSpec" label="药品规格"></el-table-column>
          <el-table-column prop="compName" label="药品生产厂家"></el-table-column>
          <el-table-column prop="approvalCode" label="批准文号"></el-table-column>
          <el-table-column prop="doseUnit" label="给药单位"></el-table-column>
        </el-table>
      </div>
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="queryInfo.page"
          :page-sizes="[20, 50, 100]"
          :page-size="queryInfo.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="this.total"
          background
        ></el-pagination>
      </div>
    </el-card>
    <el-dialog
      :title="'新增不良反应'+'——'+this.addRuleData.drugName"
      :visible.sync="dialogVisible"
      width="33%"
      :before-close="handleClose"
    >
      <div class="addRuleAdverse">
        <el-form
          :inline="true"
          :model="addRuleData"
          class="demo-form-inline addForm"
          label-width="150px"
        >
          <!-- <el-form-item label="药品编码">
            <el-input v-model="addRuleData.drugName" size="medium">
              <el-button slot="append" @click="selectCode">选择</el-button>
            </el-input>
          </el-form-item>-->
          <el-form-item label="给药类型">
            <el-select v-model="addRuleData.routeType" size="medium" placeholder="请选择">
              <el-option
                v-for="item in RouteOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="给药途径">
            <el-input v-model="addRuleData.routeName" size="medium">
              <el-button slot="append" @click="selectRoute(1)">选择</el-button>
            </el-input>
          </el-form-item>
          <el-form-item label="疾病ID">
            <el-input v-model="addRuleData.diseaName" size="medium">
              <el-button slot="append" @click="selectDisease(1)">选择</el-button>
            </el-input>
          </el-form-item>
          <el-form-item label="警示级别">
            <el-select v-model="addRuleData.slcode" size="medium" placeholder="请选择">
              <el-option
                v-for="item in SlOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="警示信息">
            <!-- 大框 -->
            <el-input type="textarea" :rows="5" v-model="addRuleData.warning" size="medium"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="addRule()">新 增</el-button>
        <el-button @click="dialogVisible = false">取 消</el-button>
      </span>
    </el-dialog>
    <!-- drugCode -->
    <!-- <el-dialog
      title="选择药品"
      :visible.sync="CodeSelectVisible"
      class="editDialog"
      width="30%"
      :before-close="handleClose"
    >
      <div style="width:100%;height:527px">
        <div class="addInput">
          <el-input v-model="DrugData.srm" size="small" placeholder="请输入内容"></el-input>
          <el-button style="margin-right:8px" type="primary" size="small" @click="SearchDrug()">搜索</el-button>
        </div>
        <el-table
          :data="DrugData.DrugTableData"
          stripe
          border
          height="400"
          style="width: 100%;font-size: 10px"
          :header-cell-style="{'text-align':'center'}"
          :row-style="{height:'40px'}"
          :cell-style="{'text-align':'center',padding:'0px'}"
        >
          <el-table-column label width="35">
            <template slot-scope="scope">
              <el-radio :label="scope.row" v-model="DrugData.radioId">&nbsp;</el-radio>
            </template>
          </el-table-column>

          <el-table-column prop="id" width="80" label="编码"></el-table-column>
          <el-table-column prop="drugName" label="药品名称"></el-table-column>
        </el-table>

        <div class="dialogBlock">
          <el-pagination
            @size-change="handleSizeChange1"
            @current-change="handleCurrentChange1"
            current-page.sync="1"
            :page-size="100"
            layout="total, prev, pager, next"
            :total="DrugData.total"
          ></el-pagination>
        </div>
        <span slot="footer" class="dialog-footer">
          <div class="SortFoot">
            <el-button style="margin-right:8px" type="primary" size="small" @click="SelectDrug()">确定</el-button>
            <el-button style="margin-right:8px" @click="CodeSelectVisible = false" size="small">取消</el-button>
          </div>
        </span>
      </div>
    </el-dialog>-->
    <!-- routedesc -->

    <el-dialog
      title="选择给药途径"
      :visible.sync="RouteMatchVisible"
      class="editDialog"
      width="30%"
      :before-close="handleCloseRoute"
    >
      <div style="width:100%;height:527px">
        <div class="addInput">
          <el-input v-model="RouteData.srm" size="small" placeholder="请输入内容"></el-input>
          <el-button style="margin-right:8px" type="primary" size="small" @click="SearchRoute()">搜索</el-button>
        </div>
        <el-table
          :data="RouteData.RouteTableData"
          stripe
          border
          height="400"
          style="width: 100%;font-size: 10px"
          :header-cell-style="{'text-align':'center'}"
          :row-style="{height:'40px'}"
          :cell-style="{'text-align':'center',padding:'0px'}"
          @row-click="handleRow"
          @selection-change="handleSelectionChange"
        >
          <el-table-column label width="35">
            <template slot-scope="scope">
              <el-radio
                :label="scope.row"
                v-model="RouteData.radioId"
                @change.native="handleSelectionChange(scope.row)"
              >&nbsp;</el-radio>
            </template>
          </el-table-column>

          <el-table-column prop="id" width="80" label="编码"></el-table-column>
          <el-table-column prop="routeName" label="给药途径名称"></el-table-column>
        </el-table>
        <!-- <el-pagination background layout="prev, pager, next" :total="1000"></el-pagination> -->
        <div class="dialogBlock">
          <el-pagination
            @size-change="handleSizeChange2"
            @current-change="handleCurrentChange2"
            :current-page="RouteData.page"
            :page-size="50"
            layout="total, prev, pager, next"
            :total="RouteData.total"
          ></el-pagination>
        </div>
        <span slot="footer" class="dialog-footer">
          <div class="SortFoot">
            <el-button
              style="margin-right:8px"
              type="primary"
              size="small"
              @click="SelectRouteID()"
            >确定</el-button>
            <el-button style="margin-right:8px" @click="RouteMatchVisible = false" size="small">取消</el-button>
          </div>
        </span>
      </div>
    </el-dialog>
    <!-- Disease -->
    <el-dialog
      title="选择疾病ID"
      :visible.sync="DiseaseVisible"
      class="editDialog"
      width="30%"
      :before-close="handleClose"
    >
      <div style="width:100%;height:527px">
        <div class="addInput">
          <el-input v-model="DiseaseData.srm" size="small" placeholder="请输入内容"></el-input>
          <el-button
            style="margin-right:8px"
            type="primary"
            size="small"
            @click="SearchDisease()"
          >搜索</el-button>
        </div>
        <el-table
          :data="DiseaseData.DiseaTableData"
          stripe
          border
          height="400"
          style="width: 100%;font-size: 10px"
          :header-cell-style="{'text-align':'center'}"
          :row-style="{height:'40px'}"
          :cell-style="{'text-align':'center',padding:'0px'}"
          @row-click="handleRow1"
          @selection-change="handleSelectionChange1"
        >
          <el-table-column label width="35">
            <template slot-scope="scope">
              <el-radio
                :label="scope.row"
                v-model="DiseaseData.radioId"
                @change.native="handleSelectionChange1(scope.row)"
              >&nbsp;</el-radio>
            </template>
          </el-table-column>

          <el-table-column prop="id" width="80" label="编码"></el-table-column>
          <el-table-column prop="zdmc" label="疾病名称"></el-table-column>
        </el-table>
        <!-- <el-pagination background layout="prev, pager, next" :total="1000"></el-pagination> -->
        <div class="dialogBlock">
          <el-pagination
            @size-change="handleSizeChange3"
            @current-change="handleCurrentChange3"
            current-page.sync="1"
            :page-size="100"
            layout="total, prev, pager, next"
            :total="DiseaseData.total"
          ></el-pagination>
        </div>
        <span slot="footer" class="dialog-footer">
          <div class="SortFoot">
            <el-button
              style="margin-right:8px"
              type="primary"
              size="small"
              @click="SelectDiseaID()"
            >确定</el-button>
            <el-button style="margin-right:8px" @click="DiseaseVisible = false" size="small">取消</el-button>
          </div>
        </span>
      </div>
    </el-dialog>
    <el-dialog
      title="所有不良反应"
      :visible.sync="AdverseDrugVisible"
      class="editDialog"
      width="70%"
      stripe
      :before-close="handleClose"
    >
      <div>
        <el-card style="height:498px">
          <el-table
            :data="AdverseData.AdverseTableData"
            :header-cell-style="{'text-align':'center'}"
            :cell-style="{'text-align':'center',padding:'0px'}"
            border
            stripe
            height="450"
            style="width: 100%"
          >
            <el-table-column type="index" label="序号" fixed width="50"></el-table-column>
            <el-table-column label="操作" width="120" fixed>
              <template slot-scope="scope">
                <el-button
                  type="text"
                  style="margin-right:12px"
                  @click="showAdverseOne(scope.row.id,scope.row.drugid)"
                >查看</el-button>
                <el-button type="text" @click="open(scope.row.id,scope.row.drugid)">删除</el-button>
              </template>
            </el-table-column>
            <el-table-column prop="drugname" label="药品名称" width="150"></el-table-column>
            <el-table-column prop="routedesc" label="给药途径描述" width="150"></el-table-column>
            <el-table-column prop="diseasename" label="疾病名称"></el-table-column>
            <el-table-column prop="slcode" label="警示级别" width="100">
              <!-- 0:拦截，1：禁忌，2：不推荐，3：轻微 -->
              <template
                slot-scope="scope"
              >{{(scope.row.slcode==0)?"拦截":(scope.row.slcode==1)?"禁忌":(scope.row.slcode==2)?"不推荐":(scope.row.slcode==3)?"轻微":""}}</template>
            </el-table-column>
            <!-- routeType 给药类型 1  全身给药     2  局部给药  3  所有方式给药   0  系统默认 -->
            <el-table-column prop="routeType" label="给药类型" width="120">
              <template
                slot-scope="scope"
              >{{(scope.row.routeType==0)?"系统默认":(scope.row.routeType==1)?"全身给药":(scope.row.routeType==2)?"局部给药":(scope.row.routeType==3)?"所有方式给药":""}}</template>
            </el-table-column>
            <el-table-column prop="warning" label="警示信息"></el-table-column>
          </el-table>
          <el-pagination
            @size-change="handleSizeChange4"
            @current-change="handleCurrentChange4"
            :current-page="1"
            :page-sizes="[10, 20, 50]"
            :page-size="AdverseData.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="AdverseData.total"
          ></el-pagination>
        </el-card>
      </div>
    </el-dialog>
    <!-- 查看一套不良反应 -->
    <el-dialog
      :title="'不良反应'+'——'+this.showAdverseOneData.drugname"
      :visible.sync="AdverseDrugOne"
      width="35%"
      :before-close="handleClose"
    >
      <div class="addRuleAdverse">
        <el-form
          :inline="true"
          :model="showAdverseOneData"
          class="demo-form-inline addForm"
          label-width="150px"
        >
          <!-- <el-form-item label="药品编码">
            <el-input v-model="addRuleData.drugName" size="medium">
              <el-button slot="append" @click="selectCode">选择</el-button>
            </el-input>
          </el-form-item>-->
          <el-form-item label="给药类型">
            <el-select v-model="showAdverseOneData.routetype" size="medium" placeholder="请选择">
              <el-option
                v-for="item in RouteOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="给药途径">
            <el-input v-model="showAdverseOneData.routeName" size="medium">
              <el-button slot="append" @click="selectRoute(2)">选择</el-button>
            </el-input>
          </el-form-item>
          <el-form-item label="疾病">
            <el-input v-model="showAdverseOneData.diseasename" size="medium">
              <el-button slot="append" @click="selectDisease(2)">选择</el-button>
            </el-input>
          </el-form-item>
          <el-form-item label="警示级别">
            <el-select v-model="showAdverseOneData.slcode" size="medium" placeholder="请选择">
              <el-option
                v-for="item in SlOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="警示信息">
            <!-- 大框 -->
            <el-input type="textarea" :rows="5" v-model="showAdverseOneData.warning" size="medium"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="UpdateRuleone()">更 新</el-button>
        <el-button @click="AdverseDrugOne = false">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import {
  getReactionList,
  getDrugCode,
  getRoute,
  getDisease,
  deleteAdverseRule,
  addAdvierseOne,
  getAdverseReactionDrugList,
  showAdverseOne,
} from "@/api/rad";
export default {
  data() {
    return {
      tableHeight: 250,
      multipleSelection: {},
      queryInfo: {
        srm: "",
        page: 1,
        pageSize: 20,
      },
      total: 0,
      tableData: [],
      dialogVisible: false,
      addRuleData: {
        drugCode: "",
        drugName: "",
        routedesc: "",
        routeName: "",
        slcode: "",
        routeType: "",
        warning: "",
        icdCodes: "",
        diseaName: "",
      },
      SlOptions: [
        {
          value: 0,
          label: "拦截",
        },
        {
          value: 1,
          label: "禁忌",
        },
        {
          value: 2,
          label: "不推荐",
        },
        {
          value: 3,
          label: "轻微",
        },
      ],
      // routeType 给药类型 1  全身给药     2  局部给药  3  所有方式给药   0  系统默认
      RouteOptions: [
        {
          value: 3,
          label: "所有方式给药",
        },
        {
          value: 1,
          label: "全身给药",
        },
        {
          value: 2,
          label: "局部给药",
        },
        {
          value: 0,
          label: "系统默认",
        },
      ],
      // 选择DrugCode
      CodeSelectVisible: false,
      DrugData: {
        srm: "",
        page: 1,
        pageSize: 50,
        load: 0,
        total: 0,
        DrugTableData: [],
        radioId: [],
      },
      RouteMatchVisible: false,
      RouteData: {
        srm: "",
        page: 1,
        pageSize: 50,
        total: 0,
        RouteTableData: [],
        radioId: [],
      },
      DiseaseVisible: false,
      DiseaseData: {
        srm: "",
        page: 1,
        pageSize: 50,
        total: 0,
        DiseaTableData: [],
        radioId: [],
      },
      // 查看所有不良反应
      AdverseDrugVisible: false,
      AdverseName: "",
      AdverseData: {
        total: 0,
        page: 1,
        pageSize: 10,
        AdverseTableData: [],
      },

      // 查看一条不良反应
      AdverseDrugOne: false,
      showAdverseOneData: {
        // Adverseone: [],
        id: "",
        drugid: "",
        drugname: "",
        routedesc: "",
        diseasename: "",
        routetype: "",
        slcode: "",
        warning: "",
      },
    };
  },
  mounted: function () {
    this.$nextTick(function () {
      this.tableHeight =
        window.innerHeight - this.$refs.table.$el.offsetTop - 50;
      // 监听窗口大小变化
      let self = this;
      window.onresize = function () {
        self.tableHeight =
          window.innerHeight - self.$refs.table.$el.offsetTop - 50;
      };
    });
  },
  created: function () {
    this.getReactionList();
  },
  methods: {
    handleClose(done) {
      done();
    },
    handleCloseRoute(done) {
      this.RouteData.radioId = [];
      done();
    },
    handleSizeChange(newSize) {
      this.queryInfo.pageSize = newSize;
      this.getReactionList();
    },

    handleCurrentChange(newPage) {
      this.queryInfo.page = newPage;
      this.getReactionList();
    },
    handleSizeChange4(newSize) {
      this.AdverseData.pageSize = newSize;
      this.getAdverseReactionDrugList();
    },

    handleCurrentChange4(newPage) {
      this.AdverseData.page = newPage;
      this.getAdverseReactionDrugList();
    },
    // handleSizeChange1(newSize) {
    //   this.DrugData.pageSize = newSize;
    //   this.getDrugCode();
    // },

    // handleCurrentChange1(newPage) {
    //   this.DrugData.page = newPage;
    //   this.getDrugCode();
    // },
    handleSizeChange2(newSize) {
      this.RouteData.pageSize = newSize;
      this.getRoute();
    },
    handleCurrentChange2(newPage) {
      this.RouteData.page = newPage;
      this.getRoute();
    },
    handleSizeChange3(newSize) {
      this.DiseaseData.pageSize = newSize;
      this.getDisease();
    },
    handleCurrentChange3(newPage) {
      this.DiseaseData.page = newPage;
      this.getDisease();
    },
    async getReactionList() {
      let res = await this.$rad.getReactionList({
        srm: this.queryInfo.srm,
        page: this.queryInfo.page,
        pageSize: this.queryInfo.pageSize,
      });
      for (var i in res.rows) {
        res.rows[i].MATCHTIME = parseInt(res.rows[i].MATCHTIME) * 1000;
      }
      this.tableData = res.rows;
      this.total = res.total;
      console.log(res.rows);
    },
    getSearchList() {
      this.queryInfo.page = 1;
      // this.queryInfo.pageSize = 20;
      this.getReactionList();
    },
    SearchRoute() {
      this.RouteData.page = 1;
      this.getRoute();
    },
    SearchDisease() {
      this.getDisease();
    },

    clearEvent() {},
    async addRule() {
      console.log(this.addRuleData);
      if (this.addRuleData.routeName === "") {
        this.$message({
          type: "warning",
          message: "请选择给药途径",
        });
      } else if (this.addRuleData.diseaName === "") {
        this.$message({
          type: "warning",
          message: "请选择疾病ID",
        });
      } else if (this.addRuleData.slcode === "") {
        this.$message({
          type: "warning",
          message: "请选择警示级别",
        });
      } else if (this.addRuleData.routeType === "") {
        this.$message({
          type: "warning",
          message: "请选择给药类型",
        });
      } else if (this.addRuleData.warning === "") {
        this.$message({
          type: "warning",
          message: "警示信息为空",
        });
      } else {
        let res = await this.$rad.addAdvierseOne({
          drugCode: this.addRuleData.drugCode,
          routedesc: this.addRuleData.routedesc,
          slcode: this.addRuleData.slcode,
          // slcode: "sdf sad ",
          routeType: this.addRuleData.routeType,
          warning: this.addRuleData.warning,
          zddm: this.addRuleData.icdCodes,
        });
        console.log(res);
        if (res.code == 1) {
          this.getReactionList();
          this.dialogVisible = false;
          this.clearAddRule();
          return this.$message({
            type: "success",
            message: res.msg,
          });
        } else {
          return this.$message({
            type: "error",
            message: res.msg,
          });
        }
      }
    },
    addReactRule(drugCode, drugName) {
      this.dialogVisible = true;
      this.addRuleData.drugCode = drugCode;
      this.addRuleData.drugName = drugName;
    },
    // 选择药品编码
    selectCode() {
      this.getDrugCode();
      this.CodeSelectVisible = true;
    },
    async getDrugCode() {
      let res = await this.$rad.getDrugCode({
        srm: this.DrugData.srm,
        page: this.DrugData.page,
        pageSize: this.DrugData.pageSize,
      });
      console.log(res);
      this.DrugData.total = res.total;
      this.DrugData.DrugTableData = res.rows;
    },
    SelectDrug() {
      this.addRuleData.drugName = this.DrugData.radioId.drugName;
      this.addRuleData.drugCode = this.DrugData.radioId.drugCode;
      this.CodeSelectVisible = false;
      // this.addRuleData.splice(0);
    },
    SearchDrug() {
      this.getDrugCode();
    },
    selectRoute(load) {
      this.DrugData.load = load;
      this.getRoute();
      this.RouteMatchVisible = true;
    },
    async getRoute() {
      let res = await this.$rad.getRoute({
        srm: this.RouteData.srm,
        page: this.RouteData.page,
        pageSize: this.RouteData.pageSize,
      });

      this.RouteData.total = res.total;
      this.RouteData.RouteTableData = res.rows;
      console.log(this.RouteData.RouteTableData);
    },
    SelectRouteID() {
      if (this.RouteData.radioId.length === 0) {
        this.$message({
          type: "warning",
          message: "请选择给药途径",
        });
      } else {
        if (this.DrugData.load == 1) {
          this.addRuleData.routedesc = this.RouteData.radioId.id;
          this.addRuleData.routeName = this.RouteData.radioId.routeName;
        } else if (this.DrugData.load == 2) {
          this.showAdverseOneData.routedesc = this.RouteData.radioId.id;
          this.showAdverseOneData.routeName = this.RouteData.radioId.routeName;
        }
        this.RouteMatchVisible = false;
      }
    },
    selectDisease(load) {
      this.DiseaseData.load = load;
      this.getDisease();
      this.DiseaseVisible = true;
    },
    async getDisease() {
      let res = await this.$rad.getDisease({
        srm: this.DiseaseData.srm,
        page: this.DiseaseData.page,
        pageSize: this.DiseaseData.pageSize,
      });
      console.log(res);
      this.DiseaseData.DiseaTableData = res.rows;
      this.DiseaseData.total = res.total;
    },
    SelectDiseaID() {
      if (this.DiseaseData.radioId.length === 0) {
        this.$message({
          type: "warning",
          message: "请选择疾病",
        });
      } else {
        if (this.DiseaseData.load == 1) {
          this.addRuleData.diseaName = this.DiseaseData.radioId.zdmc;
          this.addRuleData.icdCodes = this.DiseaseData.radioId.zddm;
        } else if (this.DiseaseData.load == 2) {
          this.showAdverseOneData.diseasename = this.DiseaseData.radioId.zdmc;
          this.showAdverseOneData.zddm = this.DiseaseData.radioId.zddm;
        }

        this.DiseaseVisible = false;
      }
    },
    showRuleAdverse(adverseDrugId, drugName) {
      this.AdverseDrugVisible = true;
      this.adverseDrugId = adverseDrugId;
      this.getAdverseReactionDrugList(adverseDrugId);
    },
    async getAdverseReactionDrugList() {
      let res = await this.$rad.getAdverseReactionDrugList({
        page: this.AdverseData.page,
        pageSize: this.AdverseData.pageSize,
        adverseDrugId: this.adverseDrugId,
      });

      console.log(res);
      this.AdverseData.AdverseTableData = res.rows;
      this.AdverseData.total = res.total;
    },
    async showAdverseOne(id, drugid) {
      let res = await this.$rad.showAdverseOne({
        id: id,
        drugid: drugid,
      });
      console.log(id + " " + drugid);
      console.log(res);
      this.showAdverseOneData.id = res.data.id;
      this.showAdverseOneData.drugid = res.data.drugid;
      this.showAdverseOneData.drugname = res.data.drugname;
      this.showAdverseOneData.routedesc = res.data.routedesc;
      this.showAdverseOneData.diseasename = res.data.diseasename;
      this.showAdverseOneData.routeName = res.data.routedesc;
      this.showAdverseOneData.zddm = res.data.zddm;
      this.showAdverseOneData.routetype = res.data.routeType;
      this.showAdverseOneData.slcode = res.data.slcode;
      this.showAdverseOneData.warning = res.data.warning;
      // 摘要信息
      // this.showAdverseOneData.abstractDesc = res.data.abstractDesc;
      this.AdverseDrugOne = true;
    },
    async UpdateRuleone() {
      console.log(this.showAdverseOneData);
      let res = await this.$rad.UpdataReacRuleone({
        id: this.showAdverseOneData.id,
        // routetype: 1,
        routedesc: this.showAdverseOneData.routedesc,
        diseasename: this.showAdverseOneData.diseasename,
        slcode: this.showAdverseOneData.slcode,
        warning: this.showAdverseOneData.warning,
        routetype: this.showAdverseOneData.routetype,
        zddm: this.showAdverseOneData.zddm,
      });
      // console.log(res);
      if (res.code == 1) {
        this.AdverseDrugOne = false;
        return this.$message({
          type: "success",
          message: res.msg,
        });
      } else {
        return this.$message({
          type: "error",
          message: res.msg,
        });
      }
    },
    open(id, drugId) {
      this.$confirm("此操作将永久删除该规则, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.deleteAdverseRule(id, drugId);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    async deleteAdverseRule(id, drugId) {
      console.log(id, drugId);
      let res = await this.$rad.deleteAdverseRule({
        id: id,
        drugid: drugId,
      });
      console.log(res);
      if (res.code == 1) {
        this.getAdverseReactionDrugList();
        this.AdverseDrugOne = false;
        this.getReactionList();
        return this.$message({
          type: "success",
          message: res.msg,
        });
      } else {
        return this.$message({
          type: "error",
          message: res.msg,
        });
      }
    },
    clearAddRule() {
      this.addRuleData.drugName = "";
      this.addRuleData.routedesc = "";
      this.addRuleData.routeName = "";
      this.addRuleData.slcode = "";
      this.addRuleData.routeType = "";
      this.addRuleData.warning = "";
      this.addRuleData.icdCodes = "";
      this.addRuleData.diseaName = "";
    },
    handleRow(row) {
      console.log(row);
      this.RouteData.radioId = row;
      this.multipleSelection = row;
    },
    handleSelectionChange(val) {
      console.log(res);
      this.multipleSelection = val;
    },
    handleRow1(row) {
      console.log(row);
      this.DiseaseData.radioId = row;
      this.multipleSelection = row;
    },
    handleSelectionChange1(val) {
      console.log(res);
      this.multipleSelection = val;
    },
  },
};
</script>
<style scoped>
.SearchCard {
  height: 50px;
  font-size: 12px;
}
.SearchTitle {
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-right: 1px solid #c2c2c2;
}
.SearchLable {
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.TableCard {
  margin-left: 3px;
  margin-top: 2px;
}
.block {
  text-align: center;
  margin-top: 12px;
  margin-bottom: 12px;
}
.editDialog >>> .el-dialog__header {
  margin-bottom: 0px;
}
.editDialog >>> .el-dialog__body {
  padding-left: 0px;
  padding-right: 0px;
}
.addInput {
  height: 45px;
  display: flex;
  align-items: center;
}
.SortFoot {
  height: 50px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.addInput >>> .el-input {
  width: 40%;
  margin-left: 8px;
}
.addInput >>> .el-button {
  margin-left: 8px;
}
.dialogBlock {
  margin-top: 0px;
  margin-bottom: 0px;
}
.adverseCard >>> .el-input {
  width: 60%;
}
.adverseCard >>> .el-input {
  width: 120px;
}
.addForm >>> .el-form-item__content {
  width: 200px;
}
</style>